package ro.unibuc.nautilus.service;

import java.util.List;

import ro.unibuc.nautilus.dao.GenericDAO;
import ro.unibuc.nautilus.domain.Employee;

public class EmployeesServiceImpl implements EmployeesService {

	private GenericDAO<Employee, Long> employeesDAO;
	
	public Employee findEmployee(Long id) {
		return employeesDAO.find(id);
	}

	public List<Employee> findAll() { 
		return employeesDAO.findAll();
	}

	public void createOrUpdate(Employee employee) {
		if (employee.getId() == 0) {
			employeesDAO.create(employee);
		} else {
			employeesDAO.update(employee);
		}
	}

	public void setEmployeesDAO(GenericDAO<Employee, Long> employeesDAO) {
		this.employeesDAO = employeesDAO;
	}
}
